<?php
require_once 'WebServices.php';

/**
 * class CompanyServiceClient
 *
 */
class CompanyServiceClient {
	
	/**
	 * Search employees
	 *
	 * curl extension must be enable in php.ini
	 *
	 * @return array of employess
	 */
	public static function Select($filters = array()) {
		$providers = WebServices::Select($filters);
		
		$result = array();
		foreach ($providers as $provider) {
			$client = new SoapClient(null, array( 
			  'location' => $provider['WSURL'], 
			  'uri'      => "urn://tyler/req"
			)); 

			$emps = $client->__soapCall("search",array($filters));
			if ($emps == null) continue;

			foreach ($emps as &$emp)
 				$emp['Company'] = $provider['Company'];

 			$result = array_merge($result, $emps);
		}
		
		return $result;
	}
}
?>